import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AssetOutboundRecordsVO, AssetOutboundRecordsForm, AssetOutboundRecordsQuery } from '@/api/business/assetOutboundRecords/types';

/**
 * 查询资产出库记录列表
 * @param query
 * @returns {*}
 */

export const listAssetOutboundRecords = (query?: AssetOutboundRecordsQuery): AxiosPromise<AssetOutboundRecordsVO[]> => {
  return request({
    url: '/business/assetOutboundRecords/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询资产出库记录详细
 * @param id
 */
export const getAssetOutboundRecords = (id: string | number): AxiosPromise<AssetOutboundRecordsVO> => {
  return request({
    url: '/business/assetOutboundRecords/' + id,
    method: 'get'
  });
};

/**
 * 新增资产出库记录
 * @param data
 */
export const addAssetOutboundRecords = (data: AssetOutboundRecordsForm) => {
  return request({
    url: '/business/assetOutboundRecords',
    method: 'post',
    data: data
  });
};

/**
 * 修改资产出库记录
 * @param data
 */
export const updateAssetOutboundRecords = (data: AssetOutboundRecordsForm) => {
  return request({
    url: '/business/assetOutboundRecords',
    method: 'put',
    data: data
  });
};

/**
 * 删除资产出库记录
 * @param id
 */
export const delAssetOutboundRecords = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/assetOutboundRecords/' + id,
    method: 'delete'
  });
};

/**
 * 生成出库物资编号
 * @param id
 */
export const generateOrderNumber = () => {
  return request({
    url: '/business/assetOutboundRecords/out/generateOrderNumber',
    method: 'get'
  });
};
